package com.example.jetpack_workmanager

import android.content.Context
import android.os.SystemClock
import android.util.Log
import androidx.work.Data
import androidx.work.Worker
import androidx.work.WorkerParameters

class MyWork(context: Context, workerParams: WorkerParameters) : Worker(context, workerParams) {

    override fun doWork(): Result {
        val inputDataStr = inputData.getString("input_data")
        Log.d("MyWork", "inputData:${inputDataStr}")

        SystemClock.sleep(2000)
        Log.d("MyWork", "mywork dowork")
        //任务执行完返回数据
        val outputData = Data.Builder().putString("output_data", "执行成功").build()
        return Result.success(outputData)
    }

}



